/**
 * Create a point with x and y coordinates
 * @version 1.0
 * @param {Number} x new x coordinate
 * @param {Number} y new y coordinate
 * @param {Object} x Object literal containing x and y values
 * @returns true
 */
com.bb.geom.Point = function (x, y) {
	if (typeof x === 'number' && typeof x === 'number') {
		this.x = x;
		this.y = y;		
	}
	else if (typeof x === 'object' && typeof x.x === 'number' && typeof x.y === 'number') {
		this.x = x.x;
		this.y = x.y;
	}
	else {
		throw new Error('com.bb.geom.Point expected a coordinate pair');
	}
	return true;
};

/**
 * com.bb.geom.Point prototype object
 */
com.bb.geom.Point.prototype = {
	/**
	 * Set the X coordinate of the point
	 * @param {Number} x new x coordinate
	 * @returns true
	 */
	setX: function (x) {
		this.x = x;
		return true;
	},
	/**
	 * Set the Y coordinate of the point
	 * @param {Number} y new y coordinate
	 * @returns true
	 */
	setY: function (y) {
		this.y = y;
		return true;
	},
	/**
	 * Get the X coordinate of the point
	 * @returns {Number} x coordinate of the point
	 */
	getX: function () {
		return this.x;
	},
	/**
	 * Get the Y coordinate of the point
	 * @returns {Number} y coordinate of the point
	 */
	getY: function () {
		return this.y;
	},
	/**
	 * Set the x and y coordinate of the point
	 * @param {Number} x new x coordinate
	 * @param {Number} y new y coordinate
	 * @param {Object} x Object literal containing x and y values
	 * @returns true
	 */
	setLocation: function (x, y) {
		if (typeof x === 'number' && typeof x === 'number') {
			this.x = x;
			this.y = y;		
		}
		else if (typeof x === 'object' && typeof x.x === 'number' && typeof x.y === 'number') {
			this.x = x.x;
			this.y = x.y;
		}
		return true;
	},
	/**
	 * Get the x and y coordinates of the point
	 * @returns Object literal containing x and y values
	 */
	getLocation: function () {
		return {
			x: this.x,
			y: this.y
		};
	}
};